import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';

//列表数据
export const columns: BasicColumn[] = [
  // {
  //   title: '年',
  //   align: "center",
  //   dataIndex: 'year',
  //   sorter: true,
  // },
  {
    title: '日期',
    align: "center",
    dataIndex: 'month',
    sorter: true,
  },
  {
    title: '业务员',
    align: "center",
    dataIndex: 'salesUser'
  },
  {
    title: '代理商',
    align: "center",
    dataIndex: 'agent',
    resizable: true
  },
  {
    title: '区域',
    align: "center",
    dataIndex: 'region'
  },
  {
    title: '货品编码',
    align: "center",
    dataIndex: 'goods_no'
  },
  {
    title: '货品名称',
    align: "center",
    dataIndex: 'goods_name'
  },
  // {
  //   title: '发货数量',
  //   align: "center",
  //   dataIndex: 'sendCount',
  //   sorter: true,
  // },
  // {
  //   title: '销售数量',
  //   align: "center",
  //   dataIndex: 'saleCount',
  //   sorter: true,
  // },
  // {
  //   title: '动销率',
  //   align: "center",
  //   dataIndex: 'dsr'
  // },
  {
    title: '销售额',
    align: "center",
    dataIndex: 'paid',
    // sorter: true,
  },
  {
    title: '同比',
    align: "center",
    dataIndex: 'yoy_growth',
  },
  {
    title: '环比',
    align: "center",
    dataIndex: 'mom_growth',
  },
  // {
  //   title: '销售金额',
  //   align: "center",
  //   dataIndex: 'saleAmount',
  //   sorter: true,
  // },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "业务员",
    field: 'salesUser',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "代理商",
    field: 'agent',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "区域",
    field: 'region',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "货品编码",
    field: 'goodsNo',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "货品名称",
    field: 'goodsName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "年份",
    field: 'year',
    component: 'Input',
    defaultValue: 2025,
    //colProps: {span: 6},
  },
  {
    label: "统计维度",
    field: 'groupByType',
    component: 'JSelectMultiple',
    componentProps: {
      dictCode: "group_by_type",
      triggerChange: true
    },
    //colProps: {span: 6},
  },

];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '业务员',
    field: 'salesUser',
    component: 'Input',
  },
  {
    label: '代理商',
    field: 'agent',
    component: 'Input',
  },
  {
    label: '区域',
    field: 'region',
    component: 'Input',
  },
  {
    label: '销售日期',
    field: 'createdDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '货品编码',
    field: 'goodsNo',
    component: 'Input',
  },
  {
    label: '货品名称',
    field: 'goodsName',
    component: 'Input',
  },
  {
    label: '发货数量',
    field: 'sendCount',
    component: 'InputNumber',
  },
  {
    label: '销售数量',
    field: 'saleCount',
    component: 'InputNumber',
  },
  {
    label: '动销率',
    field: 'dsr',
    component: 'InputNumber',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  salesUser: { title: '业务员', order: 0, view: 'text', type: 'string', },
  agent: { title: '代理商', order: 1, view: 'text', type: 'string', },
  region: { title: '区域', order: 2, view: 'text', type: 'string', },
  goodsNo: { title: '货品编码', order: 4, view: 'text', type: 'string', },
  goodsName: { title: '货品名称', order: 5, view: 'text', type: 'string', },
  sendCount: { title: '发货数量', order: 6, view: 'number', type: 'number', },
  saleCount: { title: '销售数量', order: 7, view: 'number', type: 'number', },
  dsr: { title: '动销率', order: 8, view: 'number', type: 'number', },
  groupByType: { title: '统计维度', order: 9, view: 'list_multi', type: 'string', dictCode: 'group_by_type', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}